package action;

import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import basic.PageInfo;
import basic.QuerySet;
import common.BaseAction;
import interfaces.IGlobalService;
import util.ParameterUtil;
import utils.DateUtil;
import utils.StringUtil;

public class FormAction extends BaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7507534255609348887L;

	private IGlobalService globalService;
	private Map<String, Object> formMap = new LinkedHashMap<String, Object>();
	private List<LinkedHashMap<String, Object>> formList;
	private String keyNo;
	private Date dateTop;
	private Date dateEnd;

	// 通道分类报表
	public String bank() throws Exception {
		QuerySet<Object> querySet = new QuerySet<Object>();
		if (ParameterUtil.dateCombin(dateTop, dateEnd) == null) {
			dateTop = DateUtil.topOfDay(new Date());
			dateEnd = DateUtil.endOfDay(new Date());
		}
		/*
		 * select bc.bnk_no 'bnkNo',count(*) 'bcCount',sum(bc.bc_amount)
		 * 'bcTotal' from t_bc bc where bc.bc_state='1' and
		 * bc.bc_date<'2018-07-01' group by bc.bnk_no
		 */
		StringBuffer bc = new StringBuffer();
		StringBuffer bcSummary = new StringBuffer();
		bc.append(" select bc.bnk_no 'bnkNo',count(*) 'bcCount',IFNULL(sum(bc.bc_amount),0) 'bcTotal'  from t_bc bc where bc.bc_state='1'  ");
		bcSummary.append(" select count(*) 'bcCount',IFNULL(sum(bc.bc_amount),0) 'bcTotal'  from t_bc bc where bc.bc_state='1'  ");
		if (!StringUtil.isEmpty(keyNo)) {
			bc.append(" and bc.bnk_no='" + StringUtil.simple(keyNo) + "'   ");
			bcSummary.append(" and bc.bnk_no='" + StringUtil.simple(keyNo) + "'   ");
		}
		bc.append(" and bc.bc_date >='" + DateUtil.format(DateUtil.topOfDay(dateTop), DateUtil.DATETIME) + "'  ");
		bc.append(" and bc.bc_date <='" + DateUtil.format(DateUtil.endOfDay(dateEnd), DateUtil.DATETIME) + "'  ");
		bc.append(" group by bc.bnk_no ");
		bcSummary.append(" and bc.bc_date >='" + DateUtil.format(DateUtil.topOfDay(dateTop), DateUtil.DATETIME) + "'  ");
		bcSummary.append(" and bc.bc_date <='" + DateUtil.format(DateUtil.endOfDay(dateEnd), DateUtil.DATETIME) + "'  ");
		
		
		
		//对账过的数据
		StringBuffer bccheck = new StringBuffer();
		StringBuffer bccheckSummary = new StringBuffer();
		bccheck.append(" select bc.bnk_no 'bnkNo',count(*) 'bcCount',IFNULL(sum(bc.bc_amount),0) 'bcTotal'  from t_bc bc where bc.bc_state='1' and bc.bc_cstate='1' ");
		bccheckSummary.append(" select count(*) 'bcCount',IFNULL(sum(bc.bc_amount),0) 'bcTotal'  from t_bc bc where bc.bc_state='1' and bc.bc_cstate='1' ");
		if (!StringUtil.isEmpty(keyNo)) {
			bccheck.append(" and bc.bnk_no='" + StringUtil.simple(keyNo) + "'   ");
			bccheckSummary.append(" and bc.bnk_no='" + StringUtil.simple(keyNo) + "'   ");
		}
		bccheck.append(" and bc.bc_date >='" + DateUtil.format(DateUtil.topOfDay(dateTop), DateUtil.DATETIME) + "'  ");
		bccheck.append(" and bc.bc_date <='" + DateUtil.format(DateUtil.endOfDay(dateEnd), DateUtil.DATETIME) + "'  ");
		bccheck.append(" group by bc.bnk_no ");
		bccheckSummary.append(" and bc.bc_date >='" + DateUtil.format(DateUtil.topOfDay(dateTop), DateUtil.DATETIME) + "'  ");
		bccheckSummary.append(" and bc.bc_date <='" + DateUtil.format(DateUtil.endOfDay(dateEnd), DateUtil.DATETIME) + "'  ");
		
		
		

		StringBuffer cb = new StringBuffer();
		StringBuffer cbSummary = new StringBuffer();
		cb.append(" select cb.bnk_no 'bnkNo',count(*) 'cbCount',IFNULL(sum(cb.cb_amount),0) 'cbTotal'  from t_cb cb where cb.cb_state='1' ");
		cbSummary.append(" select count(*) 'cbCount',IFNULL(sum(cb.cb_amount),0) 'cbTotal'  from t_cb cb where cb.cb_state='1' ");
		if (!StringUtil.isEmpty(keyNo)) {
			cb.append(" and cb.bnk_no='" + StringUtil.simple(keyNo) + "'   ");
			cbSummary.append(" and cb.bnk_no='" + StringUtil.simple(keyNo) + "'   ");
		}
		cb.append(" and cb.cb_date >='" + DateUtil.format(DateUtil.topOfDay(dateTop), DateUtil.DATETIME) + "'  ");
		cb.append(" and cb.cb_date <='" + DateUtil.format(DateUtil.endOfDay(dateEnd), DateUtil.DATETIME) + "'  ");
		cb.append(" group by cb.bnk_no ");
		cbSummary.append(" and cb.cb_date >='" + DateUtil.format(DateUtil.topOfDay(dateTop), DateUtil.DATETIME) + "'  ");
		cbSummary.append(" and cb.cb_date <='" + DateUtil.format(DateUtil.endOfDay(dateEnd), DateUtil.DATETIME) + "'  ");

		
		
		StringBuffer cbcheck = new StringBuffer();
		StringBuffer cbcheckSummary = new StringBuffer();
		cbcheck.append(" select cb.bnk_no 'bnkNo',count(*) 'cbCount',IFNULL(sum(cb.cb_amount),0) 'cbTotal'  from t_cb cb where cb.cb_state='1' and cb.cb_cstate='1' ");
		cbcheckSummary.append(" select count(*) 'cbCount',IFNULL(sum(cb.cb_amount),0) 'cbTotal'  from t_cb cb where cb.cb_state='1' and cb.cb_cstate='1' ");
		if (!StringUtil.isEmpty(keyNo)) {
			cbcheck.append(" and cb.bnk_no='" + StringUtil.simple(keyNo) + "'   ");
			cbcheckSummary.append(" and cb.bnk_no='" + StringUtil.simple(keyNo) + "'   ");
		}
		cbcheck.append(" and cb.cb_date >='" + DateUtil.format(DateUtil.topOfDay(dateTop), DateUtil.DATETIME) + "'  ");
		cbcheck.append(" and cb.cb_date <='" + DateUtil.format(DateUtil.endOfDay(dateEnd), DateUtil.DATETIME) + "'  ");
		cbcheck.append(" group by cb.bnk_no ");
		cbcheckSummary.append(" and cb.cb_date >='" + DateUtil.format(DateUtil.topOfDay(dateTop), DateUtil.DATETIME) + "'  ");
		cbcheckSummary.append(" and cb.cb_date <='" + DateUtil.format(DateUtil.endOfDay(dateEnd), DateUtil.DATETIME) + "'  ");
		
		
		
		querySet = new QuerySet<Object>();
		querySet.setSqlInfo(bc.toString());
		querySet.setPageInfo(new PageInfo(1, Integer.MAX_VALUE));
		formList = globalService.search(querySet).getResultList();
		formMap.put("bcList", formList);

		querySet = new QuerySet<Object>();
		querySet.setSqlInfo(bcSummary.toString());
		querySet.setPageInfo(new PageInfo(1, Integer.MAX_VALUE));
		formList = globalService.search(querySet).getResultList();
		formMap.put("bcSummary", formList.get(0));
		
		
		querySet = new QuerySet<Object>();
		querySet.setSqlInfo(bccheck.toString());
		querySet.setPageInfo(new PageInfo(1, Integer.MAX_VALUE));
		formList = globalService.search(querySet).getResultList();
		formMap.put("bccheckList", formList);

		querySet = new QuerySet<Object>();
		querySet.setSqlInfo(bccheckSummary.toString());
		querySet.setPageInfo(new PageInfo(1, Integer.MAX_VALUE));
		formList = globalService.search(querySet).getResultList();
		formMap.put("bccheckSummary", formList.get(0));
		

		querySet = new QuerySet<Object>();
		querySet.setSqlInfo(cb.toString());
		querySet.setPageInfo(new PageInfo(1, Integer.MAX_VALUE));
		formList = globalService.search(querySet).getResultList();
		formMap.put("cbList", formList);

		querySet = new QuerySet<Object>();
		querySet.setSqlInfo(cbSummary.toString());
		querySet.setPageInfo(new PageInfo(1, Integer.MAX_VALUE));
		formList = globalService.search(querySet).getResultList();
		formMap.put("cbSummary", formList.get(0));
		
		
		querySet = new QuerySet<Object>();
		querySet.setSqlInfo(cbcheck.toString());
		querySet.setPageInfo(new PageInfo(1, Integer.MAX_VALUE));
		formList = globalService.search(querySet).getResultList();
		formMap.put("cbcheckList", formList);

		querySet = new QuerySet<Object>();
		querySet.setSqlInfo(cbcheckSummary.toString());
		querySet.setPageInfo(new PageInfo(1, Integer.MAX_VALUE));
		formList = globalService.search(querySet).getResultList();
		formMap.put("cbcheckSummary", formList.get(0));
		return SUCCESS;
	}

	// 收支明细报表
	public String fince() throws Exception {

		QuerySet<Object> querySet = new QuerySet<Object>();
		if (ParameterUtil.dateCombin(dateTop, dateEnd) == null) {
			dateTop = DateUtil.topOfDay(new Date());
			dateEnd = DateUtil.endOfDay(new Date());
		}

		StringBuffer sm = new StringBuffer();
		StringBuffer smSummary = new StringBuffer();
		sm.append(" select sm.sm_type 'smType',count(*) 'smCount',IFNULL(sum(sm.sm_amount),0) 'smTotal'   from t_sm sm where sm.sm_state='1'  ");
		smSummary.append(" select count(*) 'smCount',IFNULL(sum(sm.sm_amount),0) 'smTotal'   from t_sm sm where sm.sm_state='1' ");
		sm.append(" and sm.sm_date >='" + DateUtil.format(DateUtil.topOfDay(dateTop), DateUtil.DATETIME) + "'  ");
		sm.append(" and sm.sm_date <='" + DateUtil.format(DateUtil.endOfDay(dateEnd), DateUtil.DATETIME) + "'  ");
		sm.append(" group by sm.sm_type ");
		smSummary.append(" and sm.sm_date >='" + DateUtil.format(DateUtil.topOfDay(dateTop), DateUtil.DATETIME) + "'  ");
		smSummary.append(" and sm.sm_date <='" + DateUtil.format(DateUtil.endOfDay(dateEnd), DateUtil.DATETIME) + "'  ");

		StringBuffer ms = new StringBuffer();
		StringBuffer msSummary = new StringBuffer();
		ms.append(" select ms.ms_type 'msType',count(*) 'msCount',IFNULL(sum(ms.ms_amount),0) 'msTotal'   from t_ms ms where ms.ms_state='1'  ");
		msSummary.append(" select count(*) 'msCount',IFNULL(sum(ms.ms_amount),0) 'msTotal'   from t_ms ms where ms.ms_state='1' ");
		ms.append(" and ms.ms_date >='" + DateUtil.format(DateUtil.topOfDay(dateTop), DateUtil.DATETIME) + "'  ");
		ms.append(" and ms.ms_date <='" + DateUtil.format(DateUtil.endOfDay(dateEnd), DateUtil.DATETIME) + "'  ");
		ms.append(" group by ms.ms_type ");
		msSummary.append(" and ms.ms_date >='" + DateUtil.format(DateUtil.topOfDay(dateTop), DateUtil.DATETIME) + "'  ");
		msSummary.append(" and ms.ms_date <='" + DateUtil.format(DateUtil.endOfDay(dateEnd), DateUtil.DATETIME) + "'  ");

		StringBuffer sc = new StringBuffer();
		StringBuffer scSummary = new StringBuffer();
		sc.append(" select sc.sc_type 'scType',count(*) 'scCount',IFNULL(sum(sc.sc_amount),0) 'scTotal'   from t_sc sc where sc.sc_state='1'  ");
		scSummary.append(" select count(*) 'scCount',IFNULL(sum(sc.sc_amount),0) 'scTotal'   from t_sc sc where sc.sc_state='1' ");
		sc.append(" and sc.sc_date >='" + DateUtil.format(DateUtil.topOfDay(dateTop), DateUtil.DATETIME) + "'  ");
		sc.append(" and sc.sc_date <='" + DateUtil.format(DateUtil.endOfDay(dateEnd), DateUtil.DATETIME) + "'  ");
		sc.append(" group by sc.sc_type ");
		scSummary.append(" and sc.sc_date >='" + DateUtil.format(DateUtil.topOfDay(dateTop), DateUtil.DATETIME) + "'  ");
		scSummary.append(" and sc.sc_date <='" + DateUtil.format(DateUtil.endOfDay(dateEnd), DateUtil.DATETIME) + "'  ");

		StringBuffer cs = new StringBuffer();
		StringBuffer csSummary = new StringBuffer();
		cs.append(" select cs.cs_type 'csType',count(*) 'csCount',IFNULL(sum(cs.cs_amount),0) 'csTotal'   from t_cs cs where cs.cs_state='1'  ");
		csSummary.append(" select count(*) 'csCount',IFNULL(sum(cs.cs_amount),0) 'csTotal'   from t_cs cs where cs.cs_state='1' ");
		cs.append(" and cs.cs_date >='" + DateUtil.format(DateUtil.topOfDay(dateTop), DateUtil.DATETIME) + "'  ");
		cs.append(" and cs.cs_date <='" + DateUtil.format(DateUtil.endOfDay(dateEnd), DateUtil.DATETIME) + "'  ");
		cs.append(" group by cs.cs_type ");
		csSummary.append(" and cs.cs_date >='" + DateUtil.format(DateUtil.topOfDay(dateTop), DateUtil.DATETIME) + "'  ");
		csSummary.append(" and cs.cs_date <='" + DateUtil.format(DateUtil.endOfDay(dateEnd), DateUtil.DATETIME) + "'  ");

		querySet = new QuerySet<Object>();
		querySet.setSqlInfo(sm.toString());
		querySet.setPageInfo(new PageInfo(1, Integer.MAX_VALUE));
		formList = globalService.search(querySet).getResultList();
		formMap.put("smList", formList);

		querySet = new QuerySet<Object>();
		querySet.setSqlInfo(smSummary.toString());
		querySet.setPageInfo(new PageInfo(1, Integer.MAX_VALUE));
		formList = globalService.search(querySet).getResultList();
		formMap.put("smSummary", formList.get(0));

		querySet = new QuerySet<Object>();
		querySet.setSqlInfo(ms.toString());
		querySet.setPageInfo(new PageInfo(1, Integer.MAX_VALUE));
		formList = globalService.search(querySet).getResultList();
		formMap.put("msList", formList);

		querySet = new QuerySet<Object>();
		querySet.setSqlInfo(msSummary.toString());
		querySet.setPageInfo(new PageInfo(1, Integer.MAX_VALUE));
		formList = globalService.search(querySet).getResultList();
		formMap.put("msSummary", formList.get(0));

		querySet = new QuerySet<Object>();
		querySet.setSqlInfo(sc.toString());
		querySet.setPageInfo(new PageInfo(1, Integer.MAX_VALUE));
		formList = globalService.search(querySet).getResultList();
		formMap.put("scList", formList);

		querySet = new QuerySet<Object>();
		querySet.setSqlInfo(scSummary.toString());
		querySet.setPageInfo(new PageInfo(1, Integer.MAX_VALUE));
		formList = globalService.search(querySet).getResultList();
		formMap.put("scSummary", formList.get(0));

		querySet = new QuerySet<Object>();
		querySet.setSqlInfo(cs.toString());
		querySet.setPageInfo(new PageInfo(1, Integer.MAX_VALUE));
		formList = globalService.search(querySet).getResultList();
		formMap.put("csList", formList);

		querySet = new QuerySet<Object>();
		querySet.setSqlInfo(csSummary.toString());
		querySet.setPageInfo(new PageInfo(1, Integer.MAX_VALUE));
		formList = globalService.search(querySet).getResultList();
		formMap.put("csSummary", formList.get(0));

		return SUCCESS;
	}

	// 商户收支明细报表
	public String merchant() throws Exception {

		QuerySet<Object> querySet = new QuerySet<Object>();
		if (ParameterUtil.dateCombin(dateTop, dateEnd) == null) {
			dateTop = DateUtil.topOfDay(new Date());
			dateEnd = DateUtil.endOfDay(new Date());
		}

		StringBuffer sm = new StringBuffer();
		StringBuffer smSummary = new StringBuffer();
		sm.append(" select sm.sm_type 'smType',count(*) 'smCount',IFNULL(sum(sm.sm_amount),0) 'smTotal'   from t_sm sm where sm.sm_state='1'  ");
		smSummary.append(" select count(*) 'smCount',IFNULL(sum(sm.sm_amount),0) 'smTotal'   from t_sm sm where sm.sm_state='1' ");
		if (!StringUtil.isEmpty(keyNo)) {
			sm.append(" and sm.mer_no='" + StringUtil.simple(keyNo) + "'   ");
			smSummary.append(" and sm.mer_no='" + StringUtil.simple(keyNo) + "'   ");
		}
		sm.append(" and sm.sm_date >='" + DateUtil.format(DateUtil.topOfDay(dateTop), DateUtil.DATETIME) + "'  ");
		sm.append(" and sm.sm_date <='" + DateUtil.format(DateUtil.endOfDay(dateEnd), DateUtil.DATETIME) + "'  ");
		sm.append(" group by sm.sm_type ");
		smSummary.append(" and sm.sm_date >='" + DateUtil.format(DateUtil.topOfDay(dateTop), DateUtil.DATETIME) + "'  ");
		smSummary.append(" and sm.sm_date <='" + DateUtil.format(DateUtil.endOfDay(dateEnd), DateUtil.DATETIME) + "'  ");

		StringBuffer ms = new StringBuffer();
		StringBuffer msSummary = new StringBuffer();
		ms.append(" select ms.ms_type 'msType',count(*) 'msCount',IFNULL(sum(ms.ms_amount),0) 'msTotal'   from t_ms ms where ms.ms_state='1'  ");
		msSummary.append(" select count(*) 'msCount',IFNULL(sum(ms.ms_amount),0) 'msTotal'   from t_ms ms where ms.ms_state='1' ");
		if (!StringUtil.isEmpty(keyNo)) {
			ms.append(" and ms.mer_no='" + StringUtil.simple(keyNo) + "'   ");
			msSummary.append(" and ms.mer_no='" + StringUtil.simple(keyNo) + "'   ");
		}
		ms.append(" and ms.ms_date >='" + DateUtil.format(DateUtil.topOfDay(dateTop), DateUtil.DATETIME) + "'  ");
		ms.append(" and ms.ms_date <='" + DateUtil.format(DateUtil.endOfDay(dateEnd), DateUtil.DATETIME) + "'  ");
		ms.append(" group by ms.ms_type ");
		msSummary.append(" and ms.ms_date >='" + DateUtil.format(DateUtil.topOfDay(dateTop), DateUtil.DATETIME) + "'  ");
		msSummary.append(" and ms.ms_date <='" + DateUtil.format(DateUtil.endOfDay(dateEnd), DateUtil.DATETIME) + "'  ");

		StringBuffer bm = new StringBuffer();
		StringBuffer bmSummary = new StringBuffer();
		bm.append(" select bm.bm_type 'bmType',count(*) 'bmCount',IFNULL(sum(bm.bm_amount),0) 'bmTotal'   from t_bm bm where bm.bm_state='1'  ");
		bmSummary.append(" select count(*) 'bmCount',IFNULL(sum(bm.bm_amount),0) 'bmTotal'   from t_bm bm where bm.bm_state='1' ");
		if (!StringUtil.isEmpty(keyNo)) {
			bm.append(" and bm.mer_no='" + StringUtil.simple(keyNo) + "'   ");
			bmSummary.append(" and bm.mer_no='" + StringUtil.simple(keyNo) + "'   ");
		}
		bm.append(" and bm.bm_date >='" + DateUtil.format(DateUtil.topOfDay(dateTop), DateUtil.DATETIME) + "'  ");
		bm.append(" and bm.bm_date <='" + DateUtil.format(DateUtil.endOfDay(dateEnd), DateUtil.DATETIME) + "'  ");
		bm.append(" group by bm.bm_type ");
		bmSummary.append(" and bm.bm_date >='" + DateUtil.format(DateUtil.topOfDay(dateTop), DateUtil.DATETIME) + "'  ");
		bmSummary.append(" and bm.bm_date <='" + DateUtil.format(DateUtil.endOfDay(dateEnd), DateUtil.DATETIME) + "'  ");

		StringBuffer mb = new StringBuffer();
		StringBuffer mbSummary = new StringBuffer();
		mb.append(" select mb.mb_type 'mbType',count(*) 'mbCount',IFNULL(sum(mb.mb_amount),0) 'mbTotal'   from t_mb mb where mb.mb_state='1'  ");
		mbSummary.append(" select count(*) 'mbCount',IFNULL(sum(mb.mb_amount),0) 'mbTotal'   from t_mb mb where mb.mb_state='1' ");
		if (!StringUtil.isEmpty(keyNo)) {
			mb.append(" and mb.mer_no='" + StringUtil.simple(keyNo) + "'   ");
			mbSummary.append(" and mb.mer_no='" + StringUtil.simple(keyNo) + "'   ");
		}
		mb.append(" and mb.mb_date >='" + DateUtil.format(DateUtil.topOfDay(dateTop), DateUtil.DATETIME) + "'  ");
		mb.append(" and mb.mb_date <='" + DateUtil.format(DateUtil.endOfDay(dateEnd), DateUtil.DATETIME) + "'  ");
		mb.append(" group by mb.mb_type ");
		mbSummary.append(" and mb.mb_date >='" + DateUtil.format(DateUtil.topOfDay(dateTop), DateUtil.DATETIME) + "'  ");
		mbSummary.append(" and mb.mb_date <='" + DateUtil.format(DateUtil.endOfDay(dateEnd), DateUtil.DATETIME) + "'  ");

		querySet = new QuerySet<Object>();
		querySet.setSqlInfo(sm.toString());
		querySet.setPageInfo(new PageInfo(1, Integer.MAX_VALUE));
		formList = globalService.search(querySet).getResultList();
		formMap.put("smList", formList);

		querySet = new QuerySet<Object>();
		querySet.setSqlInfo(smSummary.toString());
		querySet.setPageInfo(new PageInfo(1, Integer.MAX_VALUE));
		formList = globalService.search(querySet).getResultList();
		formMap.put("smSummary", formList.get(0));

		querySet = new QuerySet<Object>();
		querySet.setSqlInfo(ms.toString());
		querySet.setPageInfo(new PageInfo(1, Integer.MAX_VALUE));
		formList = globalService.search(querySet).getResultList();
		formMap.put("msList", formList);

		querySet = new QuerySet<Object>();
		querySet.setSqlInfo(msSummary.toString());
		querySet.setPageInfo(new PageInfo(1, Integer.MAX_VALUE));
		formList = globalService.search(querySet).getResultList();
		formMap.put("msSummary", formList.get(0));

		querySet = new QuerySet<Object>();
		querySet.setSqlInfo(bm.toString());
		querySet.setPageInfo(new PageInfo(1, Integer.MAX_VALUE));
		formList = globalService.search(querySet).getResultList();
		formMap.put("bmList", formList);

		querySet = new QuerySet<Object>();
		querySet.setSqlInfo(bmSummary.toString());
		querySet.setPageInfo(new PageInfo(1, Integer.MAX_VALUE));
		formList = globalService.search(querySet).getResultList();
		formMap.put("bmSummary", formList.get(0));

		querySet = new QuerySet<Object>();
		querySet.setSqlInfo(mb.toString());
		querySet.setPageInfo(new PageInfo(1, Integer.MAX_VALUE));
		formList = globalService.search(querySet).getResultList();
		formMap.put("mbList", formList);

		querySet = new QuerySet<Object>();
		querySet.setSqlInfo(mbSummary.toString());
		querySet.setPageInfo(new PageInfo(1, Integer.MAX_VALUE));
		formList = globalService.search(querySet).getResultList();
		formMap.put("mbSummary", formList.get(0));

		return SUCCESS;
	}

	// 商户交易明细
	public String charge() throws Exception {

		QuerySet<Object> querySet = new QuerySet<Object>();
		if (ParameterUtil.dateCombin(dateTop, dateEnd) == null) {
			dateTop = DateUtil.topOfDay(new Date());
			dateEnd = DateUtil.endOfDay(new Date());
		}

		StringBuffer txn = new StringBuffer();
		StringBuffer txnSummary = new StringBuffer();
		txn.append(" select mer_no 'merNo',");
		txn.append(" count(case when txn_state='1' then 1 else null end) 'stateCount', ");
		txn.append(" sum(case when txn_state='1' then  txn_amount else 0 end) 'stateTotal', ");
		txn.append(" count(case when txn_refund='1' then 1 else null end) 'refundCount', ");
		txn.append(" sum(case when txn_refund='1' then  txn_amount else 0 end) 'refundTotal',  ");
		txn.append(" count(case when txn_refuse='1' then 1 else null end) 'refuseCount',  ");
		txn.append(" sum(case when txn_refuse='1' then  txn_amount else 0 end) 'refuseTotal',  ");
		txn.append(" count(case when txn_freeze='1' then 1 else null end) 'freezeCount',  ");
		txn.append(" sum(case when txn_freeze='1' then  txn_amount else 0 end) 'freezeTotal'  ");
		txn.append(" from t_transaction ");
		txn.append(" where  txn_date >='" + DateUtil.format(DateUtil.topOfDay(dateTop), DateUtil.DATETIME) + "'  and txn_date <='" + DateUtil.format(DateUtil.endOfDay(dateEnd), DateUtil.DATETIME) + "' ");
		
		txnSummary.append(" select count(*) 'txnCount', IFNULL(sum(txn_amount),0) 'txnTotal'");
		txnSummary.append(" from t_transaction ");
		txnSummary.append(" where txn_state='1' and  txn_date >='" + DateUtil.format(DateUtil.topOfDay(dateTop), DateUtil.DATETIME) + "'  and txn_date <='" + DateUtil.format(DateUtil.endOfDay(dateEnd), DateUtil.DATETIME) + "' ");
		if (!StringUtil.isEmpty(keyNo)) {
			txn.append(" and mer_no='" + StringUtil.simple(keyNo) + "'   ");
			txnSummary.append(" and mer_no='" + StringUtil.simple(keyNo) + "'   ");
		}
		txn.append(" group by mer_no ");
		txn.append(" order by mer_no asc  ");

		
		querySet = new QuerySet<Object>();
		querySet.setSqlInfo(txn.toString());
		querySet.setPageInfo(new PageInfo(1, Integer.MAX_VALUE));
		formList = globalService.search(querySet).getResultList();
		formMap.put("txnList", formList);

		querySet = new QuerySet<Object>();
		querySet.setSqlInfo(txnSummary.toString());
		querySet.setPageInfo(new PageInfo(1, Integer.MAX_VALUE));
		formList = globalService.search(querySet).getResultList();
		formMap.put("txnSummary", formList.get(0));
		return SUCCESS;
	}

	
	////////////////////// ---------------------------//////////////////////////////////////////////////////////////////////////////////////////////////////////////
	////////////////////// ---------------------------//////////////////////////////////////////////////////////////////////////////////////////////////////////////
	////////////////////// ---------------------------//////////////////////////////////////////////////////////////////////////////////////////////////////////////

	public IGlobalService getGlobalService() {
		return globalService;
	}

	public void setGlobalService(IGlobalService globalService) {
		this.globalService = globalService;
	}

	public List<LinkedHashMap<String, Object>> getFormList() {
		return formList;
	}

	public void setFormList(List<LinkedHashMap<String, Object>> formList) {
		this.formList = formList;
	}

	public Map<String, Object> getFormMap() {
		return formMap;
	}

	public void setFormMap(Map<String, Object> formMap) {
		this.formMap = formMap;
	}

	public String getKeyNo() {
		return keyNo;
	}

	public void setKeyNo(String keyNo) {
		this.keyNo = keyNo;
	}

	public Date getDateTop() {
		return dateTop;
	}

	public void setDateTop(Date dateTop) {
		this.dateTop = dateTop;
	}

	public Date getDateEnd() {
		return dateEnd;
	}

	public void setDateEnd(Date dateEnd) {
		this.dateEnd = dateEnd;
	}

}
